Index of Multiple Deprivation (IMD) 2019 Rank

Column

Column

 

Date: 2019
Source: Ministry of Housing Communities and Local Government (MHCLG)
URL: https://www.gov.uk/government/statistics/english-indices-of-deprivation-2019
Update frequency: Irregular (September 2019)

Index of Multiple Deprivation 2019 (IMD) Score

Column

Column

 

Date: 2019
Source: Ministry of Housing Communities and Local Government (MHCLG)
URL: https://www.gov.uk/government/statistics/english-indices-of-deprivation-2019
Update frequency: Irregular (September 2019)

COVID-19 vulnerability index (MSOA Level)

Column

Column

 

Date: 44166
Source: British Red Cross
URL: https://www.redcross.org.uk/
Update frequency: Regularly (British Red Cross are seeking to make regular revisions to incorporate new data)

People over the age of 65 with bad or very bad health

Column

Column

 

Date: 2011
Source: Census 2011
URL: https://www.nomisweb.co.uk/census/2011/lc3206ew
Update frequency: 10 yearly (published July 2014)

Population aged 65+

Column

Column

 

Date: 2019
Source: Office for National Statistics (ONS)
URL: https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/bulletins/annualmidyearpopulationestimates/latest
Update frequency: Annually (published September 2020)

Total population

Column

Column

 

Date: 2019
Source: Office for National Statistics (ONS)
URL: https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/bulletins/annualmidyearpopulationestimates/latest
Update frequency: Annually (published September 2020)
---
title: "ASC locality insight"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(tidyverse); library(readxl); library(sf) 
library(flexdashboard); library(viridis); library(DT); library(kableExtra);

# Disable use of scientific notation
options(scipen=999)

# Define a theme for the plots in the dashboard 
theme_set(theme_minimal())
```

```{r global, include=FALSE}

## LOCAL VARIABLES -------------------------------------------

# Name of the SLI measures spreadsheet
sli_measures_file <- "sli_measures.xlsx"

# Location of data we're using for maps
map_data_folder <- str_c(
  "S:/Public Health/Policy Performance Communications/Business Intelligence/",
  "Projects/AdultSocialCare/ASC_SNA/demographics/data")

# Name of the ASC SLI data file
asc_sli_file <- "df_asc_sli.rds"

# Name of the file with the ASC locality boundaries
asc_localities_sf_file <- "sf_asc_localities.rds"

# Name of the file with the SLI metadata
sli_measure_with_meta_file <- "df_sli_measure_with_meta.rds"

## READ & TRANSFORM ------------------------------------------

# Get the names of the ASC SLI measures that we want to include
df_asc_sli_measures <- read_xlsx(sli_measures_file) %>% 
  filter(str_to_lower(include) == "yes") %>% 
  select(-include)

# Get the ASC SLI data
df_asc_sli <- read_rds(str_c(map_data_folder, "/", asc_sli_file)) %>% #all
  filter(measure %in% df_asc_sli_measures$measure) %>% #only what we want
  pivot_wider(names_from = measure, values_from = value)

# Get the ASC locality boundaries with cross-references to LACs
sf_asc_localities <- read_rds(str_c(map_data_folder,
                                    "/", asc_localities_sf_file))

# Join the SLI data to the ASC locality boundaries
sf_asc_sli <- left_join(sf_asc_localities, df_asc_sli, 
                        by = c("ca_name" = "area")) %>% 
  relocate(c(X, Y), .before = geom)

# Get the metadata
df_sli_measure_with_meta <- read_rds(str_c(map_data_folder, "/", 
                                           sli_measure_with_meta_file)) %>% 
  filter(measure %in% df_asc_sli_measures$measure) %>% 
  select(-include) %>% 
  rename("Date:" = date, "Source:" = source, 
         "URL:" = url, "Update frequency:" = update_frequency) %>% 
  pivot_longer(!c(theme, measure), 
               names_to = "meta_attr", values_to = "meta_value")
```

```{r render subpages, include=FALSE}
# Create variable which stores all subpages outputs
out = NULL

# Set knitr options to allow duplicate labels (needed for the subpages)
options(knitr.duplicate.label = 'allow')

# Create temporary environment which we use for knitting subpage.RMD
subpage_env <- new.env()

# Get list of unique themes
df_themes <- df_asc_sli_measures %>% 
  select(theme) %>% 
  unique()

# Provide a menu header for each theme
for (menu_theme in df_themes$theme) {
  
  # Filter data on theme
  sf_asc_sli_theme <- sf_asc_sli %>% 
    filter(theme == menu_theme)
  
  # Filter measures on theme
  df_asc_sli_measures_theme <- df_asc_sli_measures %>% 
    filter(theme == menu_theme)

  # Provide a menu item for each measure
  for (measure_item in df_asc_sli_measures_theme$measure) {
    
    # Filter data for the measure 
    subpage_data <- sf_asc_sli_theme %>% 
      select(1:4, all_of(measure_item), c(X, Y, geom))
    
    # Filter metadata for the measure 
    subpage_metadata <- df_sli_measure_with_meta %>% 
      filter(theme == menu_theme & measure == measure_item) %>% 
      select(-theme, -measure)
    
    # Assign filtered data, theme & measure, and metadata to subpage_env 
    assign("subpage_data", subpage_data, subpage_env)
    assign(menu_theme, measure_item, subpage_env)
    assign("subpage_metadata", subpage_metadata, subpage_env)
    
    # Knit subpage.RMD using the subpage_env and add result to out vector
    out = c(out, knitr::knit_child('asc_sli_subpage.Rmd', 
                                   envir = subpage_env))
  }
}
```

`r paste(knitr::knit_child(text = out), collapse = '')`